
def dfs(nums, depth, res, path, used):
    if (depth == len(nums)):
        res.append(path.copy())
        return
    for i in range(len(nums)):
        # 如果用过了
        if used[i]:
            continue
        path.append(nums[i])
        used[i] = True
        dfs(nums, depth + 1, res, path, used)
        # 回溯
        used[i] = False
        path.pop()




class Solution:

    def permute(self, nums):
        used = []
        depth = 0
        res = []
        path = []
        for _ in range(len(nums)):
            used.append(False)
        if len(nums) == 0:
            return res
        dfs(nums, 0, res, path, used)
        return res

print(Solution.permute(self=None, nums = [0,1]))